const { sequelize } = require('./dao/dbConnect');
const MigrationManager = require('./scripts/migrate');

async function testMigration() {
  try {
    console.log('开始测试数据库迁移...');
    
    // 测试数据库连接
    await sequelize.authenticate();
    console.log('✅ 数据库连接成功');
    
    // 创建迁移管理器
    const manager = new MigrationManager();
    
    // 显示迁移状态
    await manager.status();
    
    // 执行迁移
    await manager.migrate();
    
    // 检查表是否创建成功
    const tables = await sequelize.getQueryInterface().showAllTables();
    console.log('\n📋 当前数据库表:');
    tables.forEach(table => {
      console.log(`   - ${table}`);
    });
    
    console.log('\n🎉 迁移测试完成！');
    
  } catch (error) {
    console.error('❌ 迁移测试失败:', error.message);
    console.error(error.stack);
  } finally {
    await sequelize.close();
  }
}

testMigration();
